﻿Public Class KundeManagerImpl
    Inherits ManagerImpl(Of Kunde)
    Implements KundeManager

    Private Class KundeMapper
        Implements RowMapper(Of Kunde)
        Public Function map(ByRef reader As System.Data.OleDb.OleDbDataReader) As Kunde Implements RowMapper(Of Kunde).map
            Dim kunde As New Kunde()
            kunde.id = reader("id")
            kunde.firmenname = reader("firmenname")
            Return kunde
        End Function
    End Class

    Sub New()
        MyBase.New("kunde", New KundeMapper())
    End Sub

    Public Overrides Sub insert(ByRef entity As Kunde)
        Dim query As New Query()
        query.sql = "insert into " & tableName & " (firmenname) values (:firmenname)"
        query.setParameter("firmenname", entity.firmenname)
        runQuery(query)
    End Sub

    Public Overrides Sub update(ByRef entity As Kunde)
        Dim query As New Query()
        query.sql = "update " & tableName & " set firmenname=:firmenname where id=:id"
        query.setParameter("firmenname", entity.firmenname)
        query.setParameter("id", entity.id)
        runQuery(query)
    End Sub
End Class
